# Maintainer: David SEGUELA <david.seguela@delair-tech.com>

_realname=zbar
pkgbase="mingw-w64-${_realname}"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.10
pkgrel=2
pkgdesc="Application and library for reading bar codes from various sources (mingw-w64)"
arch=('any')
url="https://zbar.sourceforge.io/"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-imagemagick")
source=("https://downloads.sourceforge.net/project/${_realname}/${_realname}/${pkgver}/${_realname}-${pkgver}.tar.bz2"
        "windowsandimagemagick.patch")
sha256sums=('234efb39dbbe5cef4189cc76f37afbe3cfcfb45ae52493bfe8e191318bdbadc6'
            'a82b1d118df23ce6c811877735bf646dbe4962cdd10f95ab314517e6d5a9d048')
options=('strip' 'staticlibs')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i ../windowsandimagemagick.patch
}

build() {
  [[ -d ${srcdir}/build-${CARCH} ]] && rm -rf ${srcdir}/build-${CARCH}
  cp -rf ${srcdir}/${_realname}-${pkgver} ${srcdir}/build-${CARCH}
  cd ${srcdir}/build-${CARCH}
  ./configure --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --target=${MINGW_CHOST} \
      --without-qt \
      --without-gtk \
      --without-python \
      --disable-video
  make
}

package() {
  cd ${srcdir}/"build-"${CARCH}/
  make install DESTDIR="${pkgdir}"
}
